﻿﻿﻿<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
  <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
      <c:set var="ctx" value="${pageContext.request.contextPath}" />
      <html>

      <head>
        <title>Title</title>
        <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all" />
        <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all" />
        <link rel="stylesheet" href="${ctx}/common/common.css" media="all" />
        <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>

        <style type="text/css">
          .rowtop {
            padding: 10px;
          }

          .valtop {
            padding: 9px;
          }

          /*.form-table {*/
          /*    margin: auto;*/
          /*}*/

          .form-table td {
            width: 50%;
          }

          .layui-form-label {
            width: 100px;
          }

          /*删除弹窗超出屏幕外,强制更正*/
          .layui-layer.layui-layer-dialog {
            top: 50% !important;
          }

          .ellipsis-text {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .ellipsis-short {
            max-width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .multi-line-ellipsis {
            display: -webkit-box;
            -webkit-line-clamp: 3;
            /* 显示的行数 */
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
          }
        </style>
      </head>

      <body>
        <div class="layui-col-md12" style="position: absolute; top: 27px; right: 40px; z-index: 1;">
          <!--通用table表格-->
          <div style="float: right" class="layui-btn-group paramBtn">
            <button class="layui-btn layui-btn-primary" onclick="goback()">返回</button>
          </div>
        </div>
        <%--加了id==================================================================--%>
          <form class="layui-form" id="mainForm" action="${ctx}/enterprise/saveEnterprise" method="post"
            enctype="multipart/form-data" style="margin-top:0 !important">
            <div class="layui-fluid">
              <fieldset class="layui-elem-field layui-field-title" style="margin: 0px">
                <legend class="layui-add-title">基本信息</legend>
                <input type="hidden" name="id" value="${tenterprise.id}" />
                <input type="hidden" id="companyId" value="${tenterprise.id}" />
                <input type="hidden" name="deleteFlag" value="0" />
                <table class="form-table" style="font-size: 14px">
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">企业名称：</label></th>
                    <td>${company.companyName}</td>
                    <th><label class="layui-form-label">企业简称：</label></th>
                    <td>${tenterprise.abbreviation}</td>
                  </tr>
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">许可证编号：</label></th>
                    <td>${company.license}</td>
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;企业网址：
                      </label>
                    </th>
                    <td>${tenterprise.website}</td>
                  </tr>
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">企业法人：</label></th>
                    <td>${company.legalPerson}</td>
                    <th><label class="layui-form-label">统一社会信用代码：</label></th>
                    <td>${company.creditCode }</td>
                  </tr>
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">企业联系人：</label></th>
                    <td>${company.contact}</td>
                    <th><label class="layui-form-label">联系电话：</label></th>
                    <td>${company.contactPhone}</td>
                  </tr>
                  <tr style="height: 45px">
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;行业性质：
                      </label>
                    </th>
                    <td>
                      <c:forEach items="${entType }" var="ent">
                        <c:if test="${tenterprise.type==ent.code}">${ent.described }</c:if>
                      </c:forEach>
                    </td>
                    <th><label class="layui-form-label">经营类型：</label></th>
                    <td>${company.companyTypeName }</td>
                  </tr>
                  <tr style="height: 45px">
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;生产状态：
                      </label>
                    </th>
                    <td>
                      <c:forEach items="${produceType }" var="produce">
                        <c:if test="${tenterprise.productStat==produce.code}">${produce.described }</c:if>
                      </c:forEach>
                    </td>
                    <th><label class="layui-form-label">生产范围：</label></th>
                    <td>${company.businessScope }</td>
                  </tr>
                  <tr style="height: 45px">
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;所属区域:
                      </label>
                    </th>
                    <td>${areaname }</td>
                    <th><label class="layui-form-label">注册地址：</label></th>
                    <td>${company.address}</td>
                  </tr>
                  <tr style="height: 45px">
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;生产地址:
                      </label>
                    </th>
                    <td>${tenterprise.productAddress}</td>
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;电子邮箱：
                      </label>
                    </th>
                    <td>${tenterprise.email}</td>
                  </tr>
                  <tr style="height: 45px">
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;传真:
                      </label>
                    </th>
                    <td>${tenterprise.fax}</td>
                    <th>
                      <label class="layui-form-label">
                        <span style="color: red">*</span>
                        &nbsp;邮编：
                      </label>
                    </th>
                    <td>${tenterprise.postcode}</td>
                  </tr>
                  <tr>
                    <th><label class="layui-form-label">法人身份证:</label></th>
                    <td>
                      <c:if test="${company.idnumberPath != nul && company.idnumberPath != '' }">
                        <img style="width: 100px; height: 100px; cursor: pointer"
                          src="${fastUrl}${company.idnumberPath }" class="layui-upload-img"
                          onclick="previewImage('${company.idnumberPath}')"
                          onerror="this.style.display='none'; this.nextElementSibling.style.display='block';" />
                        <div style="display: none; color: #999; font-size: 12px">图片加载失败</div>
                      </c:if>
                    </td>
                    <th><label class="layui-form-label">企业简介:</label></th>
                    <td>${company.introduction }</td>
                  </tr>
                </table>
              </fieldset>

              <fieldset class="layui-elem-field layui-field-title" style="margin: 0px">
                <legend class="layui-add-title">生产许可证</legend>
                <table class="form-table" style="font-size: 14px">
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">发证日期：</label></th>
                    <td>
                      <fmt:formatDate value="${company.fcpIssueDate}" pattern="yyyy-MM-dd" />
                    </td>
                    <th><label class="layui-form-label">失效日期：</label></th>
                    <td>
                      <fmt:formatDate value="${company.fcpExpireDate}" pattern="yyyy-MM-dd" />
                    </td>
                  </tr>
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">生产许可证：</label></th>
                    <td>
                      <c:if test="${company.licensePath != nul && company.licensePath != '' }">
                        <img style="width: 100px; height: 100px; cursor: pointer"
                          src="${fastUrl}${company.licensePath }" class="layui-upload-img"
                          onclick="previewImage('${company.licensePath}')"
                          onerror="this.style.display='none'; this.nextElementSibling.style.display='block';" />
                        <div style="display: none; color: #999; font-size: 12px">图片加载失败</div>
                      </c:if>
                    </td>
                  </tr>
                </table>
              </fieldset>
              <fieldset class="layui-elem-field layui-field-title" style="margin: 0px">
                <legend class="layui-add-title">营业执照</legend>
                <table class="form-table" style="font-size: 14px">
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">发证日期：</label></th>
                    <td>
                      <fmt:formatDate value="${company.issueDate}" pattern="yyyy-MM-dd" />
                    </td>
                    <th><label class="layui-form-label">失效日期：</label></th>
                    <td>
                      <fmt:formatDate value="${company.expireDate}" pattern="yyyy-MM-dd" />
                    </td>
                  </tr>
                  <tr style="height: 45px">
                    <th><label class="layui-form-label">营业执照：</label></th>
                    <td>
                      <c:if test="${company.picPath != nul && company.picPath != '' }">
                        <img style="width: 100px; height: 100px; cursor: pointer" src="${fastUrl}${company.picPath }"
                          class="layui-upload-img" onclick="previewImage('${company.picPath}')"
                          onerror="this.style.display='none'; this.nextElementSibling.style.display='block';" />
                        <div style="display: none; color: #999; font-size: 12px">图片加载失败</div>
                      </c:if>
                    </td>
                  </tr>
                </table>
              </fieldset>
            </div>
            <%-- <!--企业变更记录-->
              <div class="layui-fluid">
                <!-- 企业变更记录-->
                <%@include file="informationList/certificationInfo.jsp" %>
              </div>
              <div class="layui-add-line"></div>
              --%>

              <div class="layui-fluid">
                <jsp:include page="informationList/companyModify.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <!--近三年销售记录-->
              <div class="layui-fluid">
                <!-- 近三年销售记录-->
                <jsp:include page="informationList/sales.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--企业停复产-->
              <div class="layui-fluid">
                <!-- 企业停复产-->
                <jsp:include page="informationList/resumption.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--资质证明-->
              <div class="layui-fluid">
                <!-- 资质证明-->
                <jsp:include page="informationList/proof.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--主要人员-->
              <div class="layui-fluid">
                <!-- 主要人员-->
                <jsp:include page="informationList/security.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--技术人员-->
              <div class="layui-fluid">
                <!-- 技术人员-->
                <jsp:include page="informationList/artisan.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--产品资质-->
              <div class="layui-fluid">
                <!-- 产品资质-->
                <jsp:include page="informationList/certificationInfo.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>

              <!--媒体报道及曝光情况-->
              <div class="layui-fluid">
                <!-- 媒体报道及曝光情况-->
                <jsp:include page="informationList/exposure.jsp">
                  <jsp:param name="enterpriseId" value="${tenterprise.id}" />
                  <jsp:param name="viewMode" value="true" />
                </jsp:include>
              </div>
              <div class="layui-add-line"></div>
          </form>

          <script>
            //预览图片
            function previewImage(src) {
              console.log("原始路径:", src); // 调试信息
              // 确保路径正确
              var fullPath = src.startsWith("/") ? "${fastUrl}" + src : "${fastUrl}/" + src;
              console.log("完整路径:", fullPath); // 调试信息

              // 使用原生 JavaScript 创建模态框
              var modal = document.createElement("div");
              modal.style.cssText =
                "position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; justify-content: center; align-items: center;";
              modal.onclick = function () {
                document.body.removeChild(modal);
              };

              var imgContainer = document.createElement("div");
              imgContainer.style.cssText =
                "position: relative; max-width: 90%; max-height: 90%; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);";
              imgContainer.onclick = function (e) {
                e.stopPropagation();
              };

              var closeBtn = document.createElement("div");
              closeBtn.innerHTML = "×";
              closeBtn.style.cssText =
                "position: absolute; top: 10px; right: 15px; font-size: 24px; color: #999; cursor: pointer; z-index: 10000;";
              closeBtn.onclick = function () {
                document.body.removeChild(modal);
              };

              var img = document.createElement("img");
              img.src = fullPath;
              img.style.cssText = "max-width: 100%; max-height: 500px; display: block;";
              img.onerror = function () {
                console.log("图片加载失败，路径:", this.src);
                img.style.display = "none";
                var errorDiv = document.createElement("div");
                errorDiv.innerHTML = "图片加载失败，请检查路径: " + fullPath;
                errorDiv.style.cssText = "color: #999; font-size: 14px; text-align: center; padding: 20px;";
                imgContainer.appendChild(errorDiv);
              };

              imgContainer.appendChild(closeBtn);
              imgContainer.appendChild(img);
              modal.appendChild(imgContainer);
              document.body.appendChild(modal);
            }

            // 返回按钮处理
            function goback() {
              window.location.href = "${ctx}/enterprise/enterprisePage";
            }
            //Demo
            layui.use("form", function () {
              var form = layui.form;

              //监听提交
              form.on("submit(formDemo)", function (data) {
                layer.load(1, {
                  shade: [0.1, "#fff"], //0.1透明度的白色背景
                });
                $("#formBtn").attr("disabled", true);
              });
            });

            layui.use("laydate", function () {
              var laydate = layui.laydate;
              //执行一个laydate实例
              laydate.render({
                elem: "#approval_time", //指定元素
                type: "datetime",
              });
            });
          </script>
      </body>

      </html>